home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / imageto / image-char.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-20  |  2.0 KB  |  70 lines

  1. /* image-char.c: manipulate information about the characters in the image.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include "config.h"
  20.  
  21. #include "image-char.h"
  22.  
  23.  
  24. /* Return an initialized, empty list.  */
  25. image_char_list_type
  26. new_image_char_list ()
  27. {
  28.   image_char_list_type l;
  29.   
  30.   IMAGE_CHAR_LIST_LENGTH (l) = 0;
  31.   IMAGE_CHAR_LIST_DATA (l) = NULL;
  32.   
  33.   return l;
  34. }
  35.  
  36.  
  37. /* Append the character C to the list L.  */
  38.  
  39. void
  40. append_image_char (image_char_list_type *l, image_char_type c)
  41. {
  42.   IMAGE_CHAR_LIST_LENGTH (*l)++;
  43.   IMAGE_CHAR_LIST_DATA (*l)
  44.     = xrealloc (IMAGE_CHAR_LIST_DATA (*l),
  45.                   IMAGE_CHAR_LIST_LENGTH (*l) * sizeof (image_char_type));
  46.   IMAGE_CHAR (*l, IMAGE_CHAR_LIST_LENGTH (*l) - 1) = c;
  47. }
  48.  
  49.  
  50. /* Return false if the box BOX_COUNT boxes beyond CURRENT_CHAR in LIST
  51.    is in the middle of a character, true otherwise.  To do this, we must
  52.    add up all the box counts for characters starting at FIRST_CHAR,
  53.    until we see where we land.  */
  54.  
  55. boolean
  56. box_at_char_boundary_p (image_char_list_type list, unsigned current_char,
  57.                         unsigned box_count)
  58. {
  59.   unsigned count = 0;
  60.   
  61.   while (count < box_count && current_char < IMAGE_CHAR_LIST_LENGTH (list))
  62.     {
  63.       image_char_type c = IMAGE_CHAR (list, current_char);
  64.       count += IMAGE_CHAR_BB_COUNT (c);
  65.       current_char++;
  66.     }
  67.     
  68.   return count == box_count;
  69. }
  70.